package com.jsjvm.client.execution.objrepr;

import com.google.gwt.core.client.GWT;
import com.jsjvm.client.classparser.JClass;
import com.jsjvm.client.execution.JClassLoader.JClassNotLoadedException;
import com.jsjvm.client.execution.objrepr.java.JavaArrayRepr;
import com.jsjvm.client.execution.objrepr.java.JavaObjectRepr;

public class ObjectFactory {
	public static ObjectRepr newObject(JClass jc){
		if (GWT.isScript()){
			return JavaObjectRepr.newJavaObjectRepr(jc);
			// TODO: return NativeObjectRepr.newNativeObjectRepr(jc);
		} else {
			return JavaObjectRepr.newJavaObjectRepr(jc);
		}
	}
	
	public static ArrayRepr newArray(String type, int size) throws JClassNotLoadedException{
		if (GWT.isScript()){
			return JavaArrayRepr.newJavaArrayRepr(type, size);
			// TODO: return NativeObjectRepr.newNativeArrayObjectRepr(size);
		} else {
			return JavaArrayRepr.newJavaArrayRepr(type, size);
		}
	}
	
	
}
